<?php

namespace App\Http\Resources;

use App\Models\SurveyFill;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;

class SurveyFillResource extends JsonResource
{
    /**
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'suvery' => new SurveyResource($this->survey),
            'answers' => json_decode($this->answers,true),
            'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
            'updated_at' => Carbon::parse($this->updated_at)->format('Y-m-d H:i:s'),
        ];
    }
}
